using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EcsSiteDSTableAdapters;
using System.ComponentModel;

/// <summary>
/// Summary description for EmpPostTypeBLL
/// </summary>
/// 
namespace SiteECSWeb
{
    [DataObject]
    public class EmpPostTypeBLL
    {

        private EmpPostTypeTableAdapter _EmpPostTypeAdapter = null;

        protected EmpPostTypeTableAdapter EmpPostTypeAdapter
        {
            get
            {
                if (_EmpPostTypeAdapter == null)
                {
                    _EmpPostTypeAdapter = new EmpPostTypeTableAdapter();
                }
                return _EmpPostTypeAdapter;
            }
        }

        #region Select EmpPostTypeDataTable

        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public EcsSiteDS.EmpPostTypeDataTable GetAllEmpPostTypeData()
        {
            return EmpPostTypeAdapter.GetEmpPostTypeData();
        }


        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmpPostTypeDataTable GetAllEmpPostTypeDataByRowRank(int RowRank)
        {
            return EmpPostTypeAdapter.GetEmpPostTypeSelectDataByRowRank(RowRank);
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public EcsSiteDS.EmpPostTypeDataTable GetEmpPostTypeByEmpPostTypeId(int EmpPostTypeId)
        {
            return EmpPostTypeAdapter.GetEmpPostTypeSelectDataByEmpPostTypeId(EmpPostTypeId);
            
        }



        #endregion

        

        #region InsertEmbassy
        [DataObjectMethodAttribute(DataObjectMethodType.Insert, true)]
        public bool AddEmpPostType(string EmpPostType_NmAr, string EmpPostType_NmEn)
        {

            EcsSiteDS.EmpPostTypeDataTable EmpPostTypeTable = new EcsSiteDS.EmpPostTypeDataTable();
            EcsSiteDS.EmpPostTypeRow EmpPostTypeRow = EmpPostTypeTable.NewEmpPostTypeRow();

            if (EmpPostType_NmAr == null) EmpPostTypeRow.SetEmpPostType_NmArNull(); else EmpPostTypeRow.EmpPostType_NmAr = EmpPostType_NmAr;
            if (EmpPostType_NmEn == null) EmpPostTypeRow.SetEmpPostType_NmEnNull(); else EmpPostTypeRow.EmpPostType_NmEn = EmpPostType_NmEn;

            EmpPostTypeTable.AddEmpPostTypeRow(EmpPostTypeRow);

            int rowsAffected = EmpPostTypeAdapter.Update(EmpPostTypeTable);

            Helper.LogActivity("Tamer beoooo",ActivityOperation.Inserted,true,
                new LogActivityInfo[] 
                    { 
                    new LogActivityInfo(EmpPostTypeTable.TableName,
                    EmpPostTypeTable.EmpPostType_NmArColumn.ColumnName,EmpPostTypeRow.EmpPostType_Id,null,EmpPostType_NmAr),
                    
                    new LogActivityInfo(EmpPostTypeTable.TableName,
                    EmpPostTypeTable.EmpPostType_NmEnColumn.ColumnName,EmpPostTypeRow.EmpPostType_Id,null,EmpPostType_NmEn)
                    }
                ); 

            //Helper.LogActivity("EmpPostType",
            //    EmpPostTypeTable.EmpPostType_NmArColumn.ColumnName,
            //    ActivityOperation.Inserted, null, EmpPostType_NmAr, "tamer basha", true);

            return rowsAffected == 1;

        }

        #endregion

        #region UpdateEmbassy

        [DataObjectMethodAttribute(DataObjectMethodType.Update, true)]
        public bool UpdateEmbassy(string EmpPostType_NmAr,
            string EmpPostType_NmEn, int EmpPostTypeId)
        {
            EcsSiteDS.EmpPostTypeDataTable EmpPostTypeTable =
                EmpPostTypeAdapter.GetEmpPostTypeSelectDataByEmpPostTypeId(EmpPostTypeId);

            if (EmpPostTypeTable.Count == 0)
            {
                return false;
            }
            EcsSiteDS.EmpPostTypeRow EmpPostTypeRow = EmpPostTypeTable[0];

            if (EmpPostType_NmAr == null) EmpPostTypeRow.SetEmpPostType_NmArNull(); else EmpPostTypeRow.EmpPostType_NmAr = EmpPostType_NmAr;
            if (EmpPostType_NmEn == null) EmpPostTypeRow.SetEmpPostType_NmEnNull(); else EmpPostTypeRow.EmpPostType_NmEn = EmpPostType_NmEn;

            int rowsAffected = EmpPostTypeAdapter.Update(EmpPostTypeRow);

            return rowsAffected == 1;
        }

        #endregion

        #region DeleteEmbassy

        [DataObjectMethodAttribute(DataObjectMethodType.Delete, true)]
        public bool DeleteEmbassy(int EmpPostTypeId)
        {
            int rowsAffected = EmpPostTypeAdapter.Delete(EmpPostTypeId);
            return rowsAffected == 1;
        }
        #endregion
    }
}
